//
//  ST_UpdateUserIntroCell.swift
//  btvideo
//
//  Created by JarvanZhang on 2019/11/10.
//  Copyright © 2019 JarvanZhang. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift


class ST_UpdateUserIntroCell: UITableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        
        
        self.contentView.addSubview(color_back_view)
        self.contentView.addSubview(titleLabel)
        self.contentView.addSubview(sign_image_view)
        self.contentView.addSubview(content_label)
        
        color_back_view.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-15)
            make.top.equalToSuperview()
            make.height.equalTo(40)
        }
        
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(color_back_view).offset(16)
            make.centerY.equalTo(color_back_view)
        }
        
        sign_image_view.snp.makeConstraints { (make) in
            make.centerY.equalTo(color_back_view)
            make.right.equalTo(color_back_view).offset(-10)
            make.width.height.equalTo(24)
        }
        
        content_label.snp.makeConstraints { (make) in
            
            make.left.equalToSuperview().offset(36)
            make.right.equalToSuperview().offset(-29)
            make.top.equalTo(color_back_view.snp.bottom).offset(5)
            
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    MARK: - Properties
    lazy var color_back_view:UIView = {
        let control = UIView()
        control.cornerRadius = 20
        control.alpha = 0.1
        return control
    }()
    
    lazy var sign_image_view:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.setImageForAllStates(ST_ImageUtils.imageName("个人中心_icon_添加")!)
        control.setImage(ST_ImageUtils.imageName("个人中心_icon_编辑关于"), for: UIControl.State.selected)
        control.isUserInteractionEnabled = false
        return control
    }()
    
    lazy var titleLabel:UILabel = {
        let control = UILabel()
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        return control
    }()
    
    lazy var content_label:UILabel = {
        let control = UILabel()
        control.numberOfLines = 0
        control.isHidden = true
        return control
    }()

//    MARK: - Bind Model
    var model = ST_ModifyUserCellModel(){
        didSet{
            
        titleLabel.text = self.model.summaryTitle
        content_label.isHidden = self.model.title.isEmpty
        sign_image_view.isSelected = !self.model.title.isEmpty
        content_label.attributedText = self.model.titleAttribute
            
            
        titleLabel.textColor = self.model.introCellColor
        color_back_view.backgroundColor = self.model.introCellColor
            
        }
    }
}
